﻿<script>
	$(document).ready(function(){
		$("#add_groupe_bdd").click(function(){
			if($("#nom").val() == "" || $("#ville").val() == ""){
				alert("Veuillez completer le formulaire !");
				return;
			}
			
			$.ajax({
			  url: "<?php echo base_url(); ?>formulaire/AjaxAddSchool",
			  type: 'POST',
			  data: {"nom":$("#nom").val(), "ville":$("#ville").val()},
			  success: function (data) {
				$("#select_school_add").append(data);
			  },
			  error: function () {
				alert("Impossible d'ajouter votre école pour le moment");
			  }
			});
			
			$("#fake_close").click();
		});
	});
</script>
<div class="container">
	<h2>S'inscrire comme jury</h2>
	<div class="col-md-6 col-lg-6">
		<form class="col-md-6 col-lg-6" action="<?php echo base_url(); ?>formulaire/inscriptionJury" method="POST">
			<div class="form-group">
				<label for="texte" class="label">Nom </label>
				<input id="text" type="text" class="form-control" position="center" name="nom" required="required">
			</div>
			<div class="form-group">
				<label for="texte" class="label">Prénom </label>
				<input id="text" type="text" class="form-control" name="prenom" required="required">    
			</div>
			<div class="form-group">
				<label for="texte" class="label">Email(login) </label>
				<input id="text" type="text" class="form-control" name="email" required="required">    
			</div>
			<div class="form-group">
				<label for="texte" class="label">Mot de passe </label>
				<input id="text" type="password" class="form-control" name="pwd" required="required">    
			</div>
			<div class="form-group">
			  <label for="select" class="label">Spécialité </label>
			  <select class="form-control" name="cats" required="required">
				<option value="" selected="selected">Matières</option>
				<?php
					foreach($cats as $cat){
						echo "<option value=\"".$cat->CAT_LIB."\">".$cat->CAT_LIB."</option>";
					}
				?>
			  </select>
			</div>
			<div class="form-group">
			  <label for="select" class="label">Représenter </label>
			  <select class="form-control" name="school" required="required" id="select_school_add">
				<option value="" selected="selected">École</option>
				<?php
					foreach($schls as $schl){
						echo "<option value=\"".$schl->PK_SCHL."\">".$schl->SCHL_LIB."</option>";
					}
				?>
			  </select>
			  <p class="ou"> ou </p>
			  
			  <div id="html">
				<p><input data-toggle="modal" data-backdrop="false" href="#formulaire" class="btn btn-pop" value="Inscrire mon école"/></p>
			  </div>
			  <div class="modal fade" id="formulaire">
				<div class="modal-dialog">
				   <div class="modal-content">
					<div class="modal-header">
					  <button type="button" class="close" data-dismiss="modal" id="fake_close">x</button>
					  <h4 class="modal-title">Inscrire une école</h4>
					</div>
					<div class="modal-body">
						<div class="form-group">
						  <label for="nom">Nom</label>
						  <input type="text" class="form-control" name ="nom" id="nom" placeholder="Votre nom">
						</div>
						<div class="form-group">
						  <label for="nom">Logo</label>	
						  <input type="file" class="filestyle" name="image">
						</div>
						<div class="form-group">						
						  <label for="nom">ville</label>
						  <input type="text" class="form-control" id ="ville" placeholder="Votre ville">
						</div>
					</div>
					<div class="modal-footer">
					  <input type="button" class="btn btn-custom" id="add_groupe_bdd" value="Valider" />
					</div>
				  </div>
				</div>			  
			</div>	
			<button type="submit" class="btn btn-custom valider">Valider</button>    
		</form>
	</div>
</div>